package entity.thread.waitNotify;


public class Foodie extends Thread {

    public void run() {
        while (true) {
            synchronized (Desk.lock) {
                if (Desk.count == 0) {
                    break;
                }
                if (Desk.foodFlag == 1) {
                    System.out.println("吃货开始吃面条，还能吃" + --Desk.count + "碗");
                    Desk.foodFlag = 0;
                    Desk.lock.notify();
                } else {
                    try {
                        Desk.lock.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }

    }
}
